<!DOCTYPE HTML>
<html>
<head>
    <title><%= __('views.addEquipment')%></title>
    <% include common/meta.ejs %>
    <% include common/public.ejs %>
    <style>
        .weui_cell_primary select {
            height: 24px;line-height: 24px;padding-left: 0;
        }
    </style>
</head>
<body>
<form class="edit-form">
    <input type="hidden" name="id" value="<%= data.info.id %>">
    <div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label"><%= __('views.subordinateStore')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <select class="weui_select"
                        emptyOption="false"
                        name="customer.id">
                    <% if(data && data.shopList) {for(var i = 0;i < data.shopList.length;i++) { %>
                    <option value="<%= data.shopList[i].id %>" <%= data.shopList[i].id==data.info.customerId?'selected':'' %>><%= data.shopList[i].name %></option>
                    <% }} %>
                </select>
            </div>
        </div>

        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label"><%= __('views.equipmentName')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" placeholder="<%= __('views.pleaseInput')%>" name="name" value="<%= data.info.name %>">
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label"><%= __('views.equipmentCode')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" placeholder="<%= __('views.pleaseInput')%>" name="code" value="<%= data.info.code %>">
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label"><%= __('views.equipmentType')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <select class="weui_select"
                        emptyOption="false"
                        name="type">
                    <option value="dtk3">DTK3</option>
                </select>
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label"><%= __('views.equipmentPosition')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" placeholder="<%= __('views.pleaseInput')%>" name="position" value="<%= data.info.position %>">
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label for="" class="weui_label"><%= __('views.recordCycle')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <select class="weui_select" name="recordPeriod" data-value="<%= data.info.recordPeriod %>">
                    <option value="5">5</option>
                    <option value="0">0</option>
                    <option selected value="10">10</option>
                    <option value="15">15</option>
                    <option value="30">30</option>
                    <option value="45">45</option>
                    <option value="60">60</option>
                </select>
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label for="" class="weui_label"><%= __('views.acquisitionCycle')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <select class="weui_select" name="uploadPeriod" data-value="<%= data.info.uploadPeriod %>">
                    <option value="5">5</option>
                    <option value="0">0</option>
                    <option value="10">10</option>
                    <option value="15">15</option>
                    <option selected value="30">30</option>
                    <option value="45">45</option>
                    <option value="60">60</option>
                </select>
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label for="" class="weui_label"><%= __('views.dataDirection')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <select class="weui_select" name="direction" data-value="<%= data.info.direction %>">
                    <option value="1" selected><%= __('views.positiveDirection')%></option>
                    <option value="0"><%= __('views.negtiveDirection')%></option>
                </select>
            </div>
        </div>
    </div>
    <div style="text-align: center;width: 75%;padding: 20px 0;margin: auto;">
        <a href="javascript:void(0);" class="weui_btn weui_btn_warn btn-submit"><%= __('views.save')%></a>
        <a href="mySheBei?openId=<%= session.openId %>" class="weui_btn weui_btn_default"><%= __('views.return')%></a>
    </div>
</form>
<% include common/footer.ejs %>
<script>
    "use strict";
    $(function () {
        Dolphin.enum.setOptions({
            ajaxFlag: true,
            enumUrl: '/api/5b8e27d5bb9547f48235bd70aea199b9@code={id}',
            cookieFlag: false
        });
        $('.btn-submit').click(function () {
            let ef = $(".edit-form");
            if (Dolphin.form.validate(ef)) {
                let data = Dolphin.form.getValue(ef, '"');
                console.log(data);
                Dolphin.ajax({
                    url: '<%= global.config.contextPath == '/' ? '' : global.config.contextPath %>/api/b6a1808e4fcd4844836eb802249ac30c',
                    type: Dolphin.requestMethod.PUT,
                    forceUrl: true,
                    data: Dolphin.json2string(data),
                    onSuccess: function (reData) {
                        location.href = 'mySheBei';
                    }
                });
            }
        });

        $(".weui_select").each(o,function () {
           let ff = $(o);
           if(ff.data('value')){
               ff.val(ff.data('value'));
           }
        });
    })
</script>
</body>
</html>